home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mush-7.1.1 / glob.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-02  |  1.9 KB  |  73 lines

  1. #ifdef BSD
  2. #define DIRECTORY
  3. #endif /* BSD */
  4.  
  5. #ifdef DIRECTORY
  6. #include <sys/dir.h>
  7. #define dirent direct
  8. #else /* !DIRECTORY */
  9.  
  10. /*
  11.  *  4.2BSD directory access emulation for non-4.2 systems.
  12.  *  Based upon routines in appendix D of Portable C and Unix System
  13.  *  Programming by J. E. Lapin (Rabbit Software).
  14.  *
  15.  *  No responsibility is taken for any error in accuracies inherent
  16.  *  either to the comments or the code of this program, but if
  17.  *  reported to me then an attempt will be made to fix them.
  18.  */
  19.  
  20. #ifndef  DEV_BSIZE
  21. #define  DEV_BSIZE  512           /* Device block size. */
  22. #endif
  23.  
  24. #define  DIRBLKSIZ  DEV_BSIZE
  25. #define  MAXNAMLEN  255           /* Name must be no longer than this. */
  26.  
  27. struct dirent
  28. {
  29.   long  d_fileno ;                /* Inode number of entry. */
  30.   short d_reclen ;                /* Length of this record. */
  31.   short d_namlen ;                /* Length of d_name string. */
  32.   char  d_name[MAXNAMLEN + 1] ;   /* Directory name. */
  33. } ;
  34.  
  35. /*  The DIRSIZ macro gives the minimum record length that will hold the
  36.  *  directory entry. This requires the amount of space in struct direct
  37.  *  without the d_name field, plus enough space for the name with a
  38.  *  terminating null byte (dp->d_namlen+1), rounded up to a 4 byte
  39.  *  boundary.
  40.  */
  41.  
  42. #undef   DIRSIZ
  43. #define  DIRSIZ(dp)                                \
  44.          ((sizeof (struct dirent) - (MAXNAMLEN+1)) \
  45.          + (((dp)->d_namlen+1 + 3) &~ 3))
  46.  
  47. /*  Definitions for library routines operating on directories. */
  48.  
  49. typedef struct _dirdesc
  50. {
  51.   int    dd_fd ;
  52.   long   dd_loc ;
  53.   long   dd_size ;
  54.   char   dd_buf[DIRBLKSIZ] ;
  55. } DIR ;
  56.  
  57. #ifndef  NULL
  58. #define  NULL  0
  59. #endif
  60.  
  61. extern  DIR              *opendir() ;
  62. extern  struct dirent    *readdir() ;
  63. extern  long             telldir() ;
  64. extern  void             seekdir() ;
  65. #define rewinddir(dirp)  seekdir((dirp), (long) 0)
  66. extern  void             closedir() ;
  67.  
  68. #endif /* DIRECTORY */
  69.  
  70. #define DELIM " \t;|"
  71. #define META "/?*[{"
  72. #define FMETA "?*[{"
  73.